Home:ALL Converter>Handling a linux system shutdown operation "gracefully"

Handling a linux system shutdown operation "gracefully"

Ask Time:2015-07-31T03:01:11         Author:MichaelCook

Json Formatter

I'm developing a python script that runs as a daemon in a linux environment. If and when I need to issue a shutdown/restart operation to the device, I want to do some cleanup and log data to a file to persist it through the shutdown.

I've looked around regarding Linux shutdown and I can't find anything detailing which, if any, signal, is sent to applications at the time of shutdown/restart. I assumed sigterm but my tests (which are not very good tests) seem to disagree with this.

Author:MichaelCook,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/31731980/handling-a-linux-system-shutdown-operation-gracefully
yy